import {get, post} from '@/http/axios'
export default {
    namespaced: true,
    state: {
        news: []
    },
    mutations: {
        // 通过突变修改news
        refreshQueryNews(state,data) {
            state.news = data
        }
    },
    actions: {
        // 删除
        async deleteNew({dispatch},id) {
            let response = await get("/article/deleteById",id)
            return response.data
        },
        // 保存修改
        async saveOrUpdateNews({dispatch},params) {
            let response = await post("/article/saveOrUpdate",params)
            return response.data.data
        },
        // 分页查询所有新闻资讯
        async queryNews({commit},params) {
            let response = await get("article/pageQuery",params)
            commit("refreshQueryNews",response.data.data)
        }
    }
}